package com.guodidi.media.file;

import com.guodidi.media.domain.enums.TraverTypeE;
import lombok.Data;

import java.nio.file.FileVisitResult;

/**
 * Created by 郭垚辉 on 2017/7/28.
 */
@Data
public class CustomVisitResult {
    private FileVisitResult preResult;
    private FileVisitResult visitorResult;
    private FileVisitResult failedResult;
    private FileVisitResult postResult;
    // 遍历的最大深度
    private Integer maxDepth;

    public CustomVisitResult() {
        this.preResult = FileVisitResult.CONTINUE;
        this.visitorResult = FileVisitResult.CONTINUE;
        this.failedResult = FileVisitResult.CONTINUE;
        this.postResult = FileVisitResult.CONTINUE;
        this.maxDepth = Integer.MAX_VALUE;
    }

    public static CustomVisitResult getResult(TraverTypeE type) {
        CustomVisitResult result = new CustomVisitResult();
        switch (type) {
            case CURRENT_DIR:
                result.setVisitorResult(FileVisitResult.SKIP_SUBTREE);
                result.setMaxDepth(1);
                break;
        }
        return result;
    }
}
